package com.lipaluma.field.mapper;

import java.lang.reflect.Field;

import com.lipaluma.context.Context;
import com.lipaluma.field.adaptor.Adaptor;
import com.lipaluma.xml.mapping.XmlFieldMapping;

/**
 * Implementations of {@link FieldMapper} have to implements {@link FieldAdapted} to allows the field mapper to adapt the value after the extraction.
 * 
 * @author mario.soares
 */
public interface FieldAdapted {

	/**
	 * Add a new adaptor to a {@link FieldMapper}
	 * 
	 * @param adaptor
	 */
	void addNewAdaptor(Adaptor adaptor);

	/**
	 * init the Adaptor using annotations
	 * @param context TODO
	 * @param field Field of the target entity
	 * 
	 * @return the Adaptor
	 */
	void initAdaptor(Context context, Field field);

	/**
	 * init the Adaptor using the xml mapping
	 * @param context TODO
	 * @param field Field of the target entity
	 * @param element the xml element
	 * @return the Adaptor
	 */
	void initAdaptor(Context context, Field field, XmlFieldMapping mapping);

	/**
	 * adapt the extracted value.
	 * @param value extracted value to adapt
	 * @return the value adapted
	 */
	String adaptValue(String value);

	/**
	 * return the field associated
	 * @return field the field
	 */
	Field getField();
}
